import os
import pathlib


def get_pipe_str_from_shell(shell):
    with os.popen(shell, 'r') as var:
        return var.read()


curpath = str(pathlib.Path(os.path.abspath(__file__)).parent)
neo4j_host = get_pipe_str_from_shell(f'''source {curpath}/SetEnv4Load.ini; echo $DB_KGEMNEO4J_IP''').strip()
neo4j_port = get_pipe_str_from_shell(f'''source {curpath}/SetEnv4Load.ini; echo $DB_KGEMNEO4J_PORT''').strip()
bolt_port = 7687
neo4j_user = get_pipe_str_from_shell(f'''source {curpath}/SetEnv4Load.ini; echo $DB_KGEMNEO4J_USER''').strip()
neo4j_passwd = get_pipe_str_from_shell(f'''source {curpath}/SetEnv4Load.ini; echo $DB_KGEMNEO4J_PWD''').strip()

syslogdir = os.path.join(curpath , 'logs')